package com.factory.iamp.pojo;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserRegister {
    private String uid;

    @NotBlank(message = "用户名不能为空")
    private String username;

    @NotBlank(message = "用户密码不能为空")
    private String password;

    @NotBlank(message = "用户真实姓名不能为空")
    private String realname;

    private int role;

    public String hashPassword() {
        return JWT.create().withAudience(this.username).sign(Algorithm.HMAC256(this.password));
    }
}